/*    */ package com.cr.common.utils;
/*    */ 
/*    */ import com.alibaba.fastjson.JSONObject;
/*    */ import com.cr.common.config.RuoYiConfig;
/*    */ import com.cr.common.utils.http.HttpUtils;
/*    */ import org.slf4j.Logger;
/*    */ import org.slf4j.LoggerFactory;
/*    */ 
/*    */ public class AddressUtils {
/* 17 */   private static final Logger log = LoggerFactory.getLogger(AddressUtils.class);
/*    */   
/*    */   public static final String IP_URL = "http://whois.pconline.com.cn/ipJson.jsp";
/*    */   
/*    */   public static final String UNKNOWN = "XX XX";
/*    */   
/*    */   public static String getRealAddressByIP(String ip) {
/* 27 */     String address = "XX XX";
/* 29 */     if (IpUtils.internalIp(ip))
/* 31 */       return "内网IP"; 
/* 33 */     if (RuoYiConfig.isAddressEnabled())
/*    */       try {
/* 37 */         String rspStr = HttpUtils.sendGet("http://whois.pconline.com.cn/ipJson.jsp", "ip=" + ip + "&json=true", "GBK");
/* 38 */         if (MyStringUtils.isEmpty(rspStr)) {
/* 40 */           log.error("获取地理位置异常 {}", ip);
/* 41 */           return "XX XX";
/*    */         } 
/* 43 */         JSONObject obj = JSONObject.parseObject(rspStr);
/* 44 */         String region = obj.getString("pro");
/* 45 */         String city = obj.getString("city");
/* 46 */         return String.format("%s %s", new Object[] { region, city });
/* 48 */       } catch (Exception e) {
/* 50 */         log.error("获取地理位置异常 {}", e);
/*    */       }  
/* 53 */     return address;
/*    */   }
/*    */ }


/* Location:              D:\tmp\creditorRights-admin\BOOT-INF\lib\creditorRights-common-4.7.0.jar!\com\cr\commo\\utils\AddressUtils.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */